﻿using System;
using Zove.Runtime;
using FunctionalCLR.Shell;
using Zove.Shell;

namespace Zove.Shell.Modelling
{
    public class ResetNode : ZoveShellContextFuncNode
    {
        public ResetNode() :
            base("reset")
        {
        }

        public override object Evaluate()
        {
            if (Parameters.Count < 1)
            {
                throw new ArgumentException(
                    "usage: reset(factor);");
            }

            string factorName
                = Convert.ToString(Parameters[0].Evaluate());
            RuntimeFactor factor
                = ZoveShellContext.GetFactor(factorName);
            if (factor != null)
            {
                factor.Status = RuntimeFactorStatus.Unknown;
                return true;
            }

            return false;
        }
    }
}
